package cn.tedu.oop2;
/**本类用于测试方法的继承*/
public class TestExtends {
    public static void main(String[] args) {
        Animal a=new Animal();
        Cat c=new Cat();
        Dog d= new Dog();
        a.eat();
        a.show();
        c.eat();
        c.show();
        d.eat();
        d.show();
        Animal show = a.show();
        System.out.println(show);//打印对象的地址值
        show.eat();
//        int aa=Animal.num();
//        System.out.println(aa);


    }

}
class Animal{

//    public static int num(){
//        return 1;
//    }


    public void eat(){
        System.out.println("小动物Animal吃啥都行");
    }
    public Animal show(){
        System.out.println("我是一只小动物~");
        Animal a=new Animal();
        return a;
    }
}
class Cat extends  Animal{
    @Override
    public void eat(){
        System.out.println("小猫爱吃小鱼干！");
    }
    @Override
    public Animal show() {
        System.out.println("我是一只小猫！");
        Animal a = new Animal();
        return a;
    }

}
class Dog extends  Animal{
    @Override
    public void eat(){
        System.out.println("小狗爱吃肉骨头");
    }
    @Override
    public Dog show(){
        System.out.println("我是一只小狗！");
        Dog a=new Dog();
        return a;
    }

}